package com.cykj.dto;

/**
 * @Program: ioc_work_0623
 * @Package: com.cykj.dto
 * @Author: 张俊杰
 * @Create: 2025-06-24 10:19
 * @Description: 响应数据格式
 * @Vision: 1.0
 **/
public class ResponseDTO {

    private int code;
    private String msg;
    private Object data;

    public ResponseDTO() {
    }

    public ResponseDTO(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    private static final Integer SUCCESS = 1;

    private static final Integer ERROR = -1;

    public static ResponseDTO success(Object obj) {
        return new ResponseDTO(SUCCESS, "success", obj);
    }

    public static ResponseDTO error() {
        return new ResponseDTO(ERROR, "error", null);
    }

    public static ResponseDTO error(String msg) {
        return new ResponseDTO(ERROR, msg, null);
    }

    public static ResponseDTO effectRow(Integer res){
        return res > 0 ? success(null) : error(null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
